const apiBase = 'http://115.190.86.189:5000/api';

function startServer() {
  fetch(`${apiBase}/start`)
    .then(res => res.json())
    .then(data => alert(data.msg))
    .catch(err => alert("启动失败"));
}

function stopServer() {
  fetch(`${apiBase}/stop`)
    .then(res => res.json())
    .then(data => alert(data.msg))
    .catch(err => alert("停止失败"));
}

function checkStatus() {
  fetch(`${apiBase}/status`)
    .then(res => res.json())
    .then(data => {
      const statusText = data.running ? "服务器正在运行" : "服务器未运行";
      document.getElementById("status").innerText = statusText;
    })
    .catch(err => alert("无法获取状态"));
}